<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Complejo extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->database();
		$this->load->library('ion_auth');
		$this->load->library('form_validation');
		$this->load->helper('url');		
		$this->load->library('twig'); // load the Twig library
		$this->twig->add_function('base_url'); // map the base_url() function as a Twig function
	}

        public function listar()
	{
            $arrayData = Array('title' => 'Complejos',
                               'is_login' => $this->ion_auth->logged_in(),
                               'is_admin' => $this->ion_auth->is_admin(),
                               'item_active' => 1,
                               'message' => (validation_errors()) ? validation_errors() : $this->session->flashdata('message'),
                               'list_users' => $this->ion_auth->users(2)->result(), // 1:admin, 2:client
            );
            
            if ($arrayData['is_login']){
                $arrayData['user'] = $this->ion_auth->user()->row();
            }
            
            foreach ($arrayData['list_users'] as $k => $user)
            {
                $arrayData['list_users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
            }  
            
            $this->twig->display('complejo/index.html.twig', $arrayData);   
	}     
        
        
        
        
        
        

}